<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>gdata.objson.objson</title>
  <link rel="stylesheet" href="epydoc.css" type="text/css"></link>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
      alink="#204080">

<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="center">
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar" align="right" width="100%">
      <table border="0" cellpadding="0" cellspacing="0">
      <tr><th class="navbar" align="center">
        <p class="nomargin">
          objson
      </p></th></tr></table>
    </th>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="100%">
      <font size="-1"><b class="breadcrumbs">
        Package&nbsp;gdata ::
        Package&nbsp;objson ::
        Module&nbsp;objson
      </b></font></br>
    </td>
    <td><table cellpadding="0" cellspacing="0">
      <tr><td align="right"><font size="-2">[show&nbsp;private&nbsp;|&nbsp;<a href="../public/gdata.objson.objson-module.html">hide&nbsp;private</a>]</font></td></tr>
      <tr><td align="right"><font size="-2">[<a href="frames.html"target="_top">frames</a>&nbsp;|&nbsp;<a href="gdata.objson.objson-module.html" target="_top">no&nbsp;frames</a>]</font></td></tr>
    </table></td>
</tr></table>

<!-- =========== START OF MODULE DESCRIPTION =========== -->
<h2 class="module">Module gdata.objson.objson</h2>

<pre class="literalblock">
A JSON feed objectifier.

It maps JSON feed raw data to local pythonic object structure
(I call it OBJson object) and provide a number of methods to access/
modify each object. Dynamically create python objects as necessary
using a superclass and a factory method.

  OBJson: superclass
    Model class called everytime when a cjson decoded JSON feed gets
    sent to the factory method. It also can be instantiated directly
    to create the top level object.
    All subclasses inherited from this superclass.

    The rule of converting:
      1. Only dict structure in JSON feed will be converted to a python object.
      The key of the dict will be the object attributes and the value
      will then be linked to each attribute respectively. The process
      is recursive until it hits String type values.
      2. If a key has '$' in it, for example, 'ns$timezone', the corresponding
      class name will be using '___' to replace the '$' sign since '$' is
      illegal in class name.
    
    A little bit of namespace handling:
      Methods provide here do not do a whole lot of error or integrity checking.
      Since its a pretty generic JSON data handling tool, the namespace handling
      has very low restrictions. As mapping to the rules of XML representation, a
      namespace declaration can be defined at any level of the element. Its the
      best practice for the programmers to maintain the integrity of the whole
      structure. For example, before adding a new child to an existing object
      structure, you should add namespace declarations first if the new child 
      introduces new namespace aliases. For example:
      
      ns = objutils.NameSpace(obj)
      if new_ns_key in ns.keys():
        obj.CreateChild(child_node)
      else:
        # you can even avoid this if you know where to add
        ns_node = objutils.GetNSNode(obj)
        if len(ns_node) == 1:   # because it allows namespace declaration on
          the_node = ns_node[0] # multiple level of JSON nodes.
          the_node.AddNameSpace(new_ns)
        obj.CreateChild(child_node)


  object methods:
  __init__:     constructor. Initialized the object.
  _ParseFile:   If input is file object, read content.
  _parse:       main function to parse the data and convert to OBJson object.
  __iter__:     make the object iterable.
  __len__:      object has length according to the size of attribute.
  ParentObj:    property manipulating parent object.
  GetAttrs:     a generator on all attributes.
  GetName:      get object class name.
  AddNameSpace: Add namespace declaration(s) to an OBJson object.
  DelNameSpace: Delete namespace declaration(s) to an OBJson object.
  UpdateNameSpace: update an existing namespace declaration.
  HasChild:     boolean to see if a object has sub OBJson objects.
  GetAttrib:    Return object attributes which do not point to an OBJson
                object.
  GetChildren:  returns all sub OBJson objects.
  AppendChild:  append a child OBJson object to the current object.
  InsertChild:  insert a child OBJson object to the current object.
  UpdateChild:  update/replace an existing OBJson object to the given one.
  DeleteChild:  delete a child object from the current object.
  MakeClone:        make a clone of the current object using object deepcopy.

  Public Functions:
  genpyobj:     subclass and object factory. It creates subclass from the given
                type and also generate an object of it. It posts the class and
                object to the global namespaces so rest of the code can see
                them.
</pre>
<hr/>

<!-- =========== START OF CLASSES =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
  <th colspan="2">Classes</th></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.OBJson-class.html"><code>OBJson</code></a></b></td>
  <td>OBJson super class for creating subclasses.</td></tr>
</table><br />


<!-- =========== START OF EXCEPTIONS =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
  <th colspan="2">Exceptions</th></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.Error-class.html"><code>Error</code></a></b></td>
  <td>&nbsp;</td></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.OBJsonAttributeError-class.html"><code>OBJsonAttributeError</code></a></b></td>
  <td>&nbsp;</td></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.OBJsonError-class.html"><code>OBJsonError</code></a></b></td>
  <td>&nbsp;</td></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.OBJsonNoKeyFoundError-class.html"><code>OBJsonNoKeyFoundError</code></a></b></td>
  <td>&nbsp;</td></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.OBJsonRuntimeError-class.html"><code>OBJsonRuntimeError</code></a></b></td>
  <td>&nbsp;</td></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.OBJsonTypeError-class.html"><code>OBJsonTypeError</code></a></b></td>
  <td>&nbsp;</td></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.OBJsonUnknownError-class.html"><code>OBJsonUnknownError</code></a></b></td>
  <td>&nbsp;</td></tr>
<tr><td width="15%">
  <b><a href="gdata.objson.objson.OBJsonValueError-class.html"><code>OBJsonValueError</code></a></b></td>
  <td>&nbsp;</td></tr>
</table><br />


<!-- =========== START OF FUNCTION SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
  <th colspan="2">Function Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1">&nbsp;</font></td>
  <td><code><span class="summary-sig"><a href="gdata.objson.objson-module.html#genpyobj" class="summary-sig-name"><code>genpyobj</code></a>(<span class=summary-sig-arg>name</span>,
          <span class=summary-sig-arg>src</span>,
          <span class=summary-sig-arg>parent</span>)</span></code>
<br />
Function to generate OBJson objects dynamically.</td></tr>
</table><br />


<!-- =========== START OF VARIABLE SUMMARY =========== -->
<table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="summary">
  <th colspan="2">Variable Summary</th></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>str</code></font></td>
<td><b><a href="gdata.objson.objson-module.html#__author__"><code>__author__</code></a></b> = <span title="'i3dmaster@gmail.com'"><code><span class="variable-quote">'</span>i3dmaster&#64;gmail.com<span class="variable-quote">'</span>                       </code>
</span></td></tr>
<tr><td align="right" valign="top" width="15%"><font size="-1"><code>int</code></font></td>
<td><b><a href="../private/gdata.objson.objson-module.html#_VMINOR"><code>_VMINOR</code></a></b> = <span title="4">4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td></tr>
</table><br />


<!-- =========== START OF FUNCTION DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
  <th colspan="2">Function Details</th></tr>
</table>

<a name="genpyobj"></a>
<table width="100%" class="func-details" bgcolor="#e0e0e0"><tr><td>
  <h3><span class="sig"><span class="sig-name">genpyobj</span>(<span class=sig-arg>name</span>,
          <span class=sig-arg>src</span>,
          <span class=sig-arg>parent</span>)</span>
  </h3>
<pre class="literalblock">
Function to generate OBJson objects dynamically.

The factory function.

Args:
  name: class name used to create the subclass
  src: cjson converted JSON feed or part of it.
  parent: The parent object who will be assigned an attribute
          using this 'name' and linked to the result object.

Returns:
  An OBJson object.
</pre>
  <dl><dt></dt><dd>
  </dd></dl>
</td></tr></table>
<br />


<!-- =========== START OF VARIABLE DETAILS =========== -->
<table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="details">
  <th colspan="2">Variable Details</th></tr>
</table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="__author__"></a>
<h3>__author__</h3>
<dl>
  <dt></dt>
  <dd>
    <dl>
      <dt><b>Type:</b></dt>
      <dd>
          <code>str</code>

      </dd>
<span title="'i3dmaster@gmail.com'">      <dt><b>Value:</b></dt>
      <dd><table><tr><td>
<pre class="variable">
<span class="variable-quote">'</span>i3dmaster&#64;gmail.com<span class="variable-quote">'</span>                                                  </pre>
        </td></tr></table></dd>
</span>    </dl>
  </dd>
</dl></td></tr></table>
<table width="100%" class="var-details" bgcolor="#e0e0e0"><tr><td>
<a name="_VMINOR"></a>
<h3>_VMINOR</h3>
<dl>
  <dt></dt>
  <dd>
    <dl>
      <dt><b>Type:</b></dt>
      <dd>
          <code>int</code>

      </dd>
<span title="4">      <dt><b>Value:</b></dt>
      <dd><table><tr><td>
<pre class="variable">
4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</pre>
        </td></tr></table></dd>
</span>    </dl>
  </dd>
</dl></td></tr></table>
<br />


<!-- =========== START OF NAVBAR =========== -->
<table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0">
  <tr valign="center">
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="trees.html">Trees</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="indices.html">Index</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar">&nbsp;&nbsp;&nbsp;<a class="navbar" href="help.html">Help</a>&nbsp;&nbsp;&nbsp;</th>
    <th class="navbar" align="right" width="100%">
      <table border="0" cellpadding="0" cellspacing="0">
      <tr><th class="navbar" align="center">
        <p class="nomargin">
          objson
      </p></th></tr></table>
    </th>
  </tr>
</table>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
  <tr>
    <td align="left"><font size="-2">Generated by Epydoc 2.1 on Mon Jul 16 16:43:14 2007</font></td>
    <td align="right"><a href="http://epydoc.sourceforge.net"
                      ><font size="-2">http://epydoc.sf.net</font></a></td>
  </tr>
</table>
</body>
</html>
